package com.neusoft.bootjdbc.dao.mapper;

import com.neusoft.bootjdbc.domain.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.sql.JDBCType;
import java.util.List;

@Mapper
public interface UserMapper {

    @Insert(value = "insert into user(user_name,password,age) values(#{user_name},#{password},#{age})")
    @Options(useGeneratedKeys = true,keyProperty = "user_id",keyColumn = "user_id")
    public int insert_user(User user);

    @Select("select * from user")
    @Results(id = "baseResult",value={
            @Result(property = "user_id",jdbcType = JdbcType.INTEGER,column = "user_id"),
            @Result(property = "user_name",jdbcType = JdbcType.VARCHAR,column = "user_name"),
            @Result(property = "password",jdbcType = JdbcType.VARCHAR,column = "password"),
            @Result(property = "age",jdbcType = JdbcType.INTEGER,column = "age")
    })
    public List<User> queryAll();

    @Select("select * from user")
    @ResultMap("baseResult")
    public List<User> queryall01();
}
